home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / JDBC / JDBC_011 / JAVA / SQL / DRIVER.JAV < prev    next >
Encoding:
Text File  |  1996-11-10  |  5.7 KB  |  142 lines

  1. /*
  2.  * Copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved.
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software
  5.  * and its documentation for NON-COMMERCIAL purposes and without
  6.  * fee is hereby granted provided that this copyright notice
  7.  * appears in all copies. Please refer to the file "LICENSE"
  8.  * for further important copyright and licensing information.
  9.  *
  10.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  11.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  12.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  13.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  14.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  15.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  16.  * 
  17.  * THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
  18.  * CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
  19.  * PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
  20.  * NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
  21.  * SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
  22.  * SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
  23.  * PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES").  SUN
  24.  * SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR
  25.  * HIGH RISK ACTIVITIES.
  26.  */
  27.  
  28. package java.sql;
  29.  
  30. /**
  31.  * <P>The Java SQL framework allows for multiple database drivers.
  32.  *
  33.  * <P>Each driver should supply a class that implements
  34.  * the Driver interface.
  35.  *
  36.  * <P>The DriverManager will try to load as many drivers as it can
  37.  * find and then for any given connection request, it will ask each
  38.  * driver in turn to try to connect to the target URL.
  39.  *
  40.  * <P>It is strongly recommended that each Driver class should be
  41.  * small and standalone so that the Driver class can be loaded and
  42.  * queried without bringing in vast quantities of supporting code.
  43.  *
  44.  * <P>When a Driver class is loaded, it should create an instance of
  45.  * itself and register it with the DriverManager. This means that a
  46.  * user can load and register a driver by doing
  47.  * Class.forName("foo.bah.Driver").
  48.  *
  49.  * @see DriverManager
  50.  * @see Connection 
  51.  */
  52. public interface Driver {
  53.  
  54.     /**
  55.      * Try to make a database connection to the given URL.
  56.      * The driver should return "null" if it realizes it is the wrong kind
  57.      * of driver to connect to the given URL.  This will be common, as when
  58.      * the JDBC driver manager is asked to connect to a given URL it passes
  59.      * the URL to each loaded driver in turn.
  60.      *
  61.      * <P>The driver should raise a SQLException if it is the right 
  62.      * driver to connect to the given URL, but has trouble connecting to
  63.      * the database.
  64.      *
  65.      * <P>The java.util.Properties argument can be used to passed arbitrary
  66.      * string tag/value pairs as connection arguments.
  67.      * Normally at least "user" and "password" properties should be
  68.      * included in the Properties.
  69.      *
  70.      * @param url The URL of the database to connect to
  71.      *
  72.      * @param info a list of arbitrary string tag/value pairs as
  73.      * connection arguments; normally at least a "user" and
  74.      * "password" property should be included
  75.      *
  76.      * @return a Connection to the URL
  77.      */
  78.     Connection connect(String url, java.util.Properties info)
  79.         throws SQLException;
  80.  
  81.     /**
  82.      * Returns true if the driver thinks that it can open a connection
  83.      * to the given URL.  Typically drivers will return true if they
  84.      * understand the subprotocol specified in the URL and false if
  85.      * they don't.
  86.      *
  87.      * @param url The URL of the database.
  88.      * @return True if this driver can connect to the given URL.  
  89.      */
  90.     boolean acceptsURL(String url) throws SQLException;
  91.  
  92.  
  93.     /**
  94.      * <p>The getPropertyInfo method is intended to allow a generic GUI tool to 
  95.      * discover what properties it should prompt a human for in order to get 
  96.      * enough information to connect to a database.  Note that depending on
  97.      * the values the human has supplied so far, additional values may become
  98.      * necessary, so it may be necessary to iterate though several calls
  99.      * to getPropertyInfo.
  100.      *
  101.      * @param url The URL of the database to connect to.
  102.      * @param info A proposed list of tag/value pairs that will be sent on
  103.      *          connect open.
  104.      * @return An array of DriverPropertyInfo objects describing possible
  105.      *          properties.  This array may be an empty array if no properties
  106.      *          are required.
  107.      */
  108.     DriverPropertyInfo[] getPropertyInfo(String url, java.util.Properties info)
  109.              throws SQLException;
  110.  
  111.  
  112.     /**
  113.      * Get the driver's major version number. Initially this should be 1.
  114.      */
  115.     int getMajorVersion();
  116.  
  117.     /**
  118.      * Get the driver's minor version number. Initially this should be 0.
  119.      */
  120.     int getMinorVersion();
  121.  
  122.  
  123.     /**
  124.      * Report whether the Driver is a genuine JDBC COMPLIANT (tm) driver.
  125.      * A driver may only report "true" here if it passes the JDBC compliance
  126.      * tests, otherwise it is required to return false.
  127.      *
  128.      * JDBC compliance requires full support for the JDBC API and full support
  129.      * for SQL 92 Entry Level.  It is expected that JDBC compliant drivers will
  130.      * be available for all the major commercial databases.
  131.      *
  132.      * This method is not intended to encourage the development of non-JDBC
  133.      * compliant drivers, but is a recognition of the fact that some vendors
  134.      * are interested in using the JDBC API and framework for lightweight
  135.      * databases that do not support full database functionality, or for
  136.      * special databases such as document information retrieval where a SQL
  137.      * implementation may not be feasible.
  138.      */
  139.     boolean jdbcCompliant();
  140.  
  141.